function edit1(e) {
    $(e).parent().parent().css("background-color", "#EBF4F5");
    // $(e).parent().parent().css("display","none");
    $.get('/dev/resume/personal', function (result) {
        let str = `<div class="resume_2_left">
                          <p>姓名：<input type="text" value="${result.data.name}" class="input1"></p>
                           <p>性别：<input type="text" value="男" style="width: 115px">学历：<input type="text" value="本科" style="width: 115px">状态：<input\n
                                       type="text" value="待业" style="width: 115px">
                     </p>
                             <p>生日：<input type="text" value="${result.data.birthday}" class="input2" style="width: 115px" >电话：<input type="text" value="${result.data.phone}" class="input3" style="width: 115px">email：<input\n
                           type="text" value="${result.data.email}" class="input4" style="width: 115px">
                  </p>
            </div>
                    <div class="mydivv" style="position: absolute;left: 760px;top: 164px;">
                    <input type="file" name="file" id="inputId">
                    <input type="submit" style="display: block" value="提交" onclick="changeImg()">
                    </div>
            <img class="lolo" src="${result.data.img}" width="40px" height="40px" alt="" style="position: absolute;top: 167px;left: 804px"  title="点击更换头像" onclick="btImg()">
<div class="ensureButton"><button onclick="enSure()">确定</button></div>`;
        $(e).parent().parent().html(str);
    })

}

function enSure() {
    $('.resume_2').css('background-color', 'white')
    let img=$('.lolo').attr('src');
    console.log(img);
    let phone = $('.input3').val()
    $.get('/dev/resume/update?phone=' + phone+'&img='+img, function (result) {
        let customer = result.data;

        let sex = '';
        if (customer.sex == 1) {
            sex = "男"
        } else {
            sex = '女';
        }

        let str = ` <div class="resume_2_left">
                        <p class="f1">${customer.name}</p>
                        <p><span class="sex">${sex}</span><span>本科</span><span>待业</span>
                        </p>
                        <p><span class="f2">${customer.birthday}</span><span class="f3">${customer.phone}</span><span
                                class="f4">${customer.email}</span>
                        </p>
                    </div>
                    <div class="resume_2_right">
                        <img class="opop" src="${customer.img}" width="40px" height="40px" alt="">
                        <p class="set1" onclick="edit1(this)">编辑</p>
                    </div>`;
        $('.resume_2').html(str);

    })
}

function editSet3(e, id) {
    $(e).parent().css("background-color", "#EBF4F5");
    $.get('/dev/resume/selectwantjob?wantJobId=' + id, function (result) {
        let wantjob = result.data
        let str = `<p>期望职位</p>
    <p style="margin-top: 20px;margin-left: 30px">期望职位：<input class="ppoo" type="text" value="${wantjob.job}" style="width: 80px">期望薪资：<input type="text" value="${wantjob.wantMoney}" style="width: 80px">期望行业：<input type="text" value="${wantjob.industry}" style="width: 80px">期望城市:<input class="nop" type="text" value="${wantjob.city}"  style="width: 80px"></p>
    <p style="position: relative;top: 8px;right: -643px;"><button style="border: 0;background-color: #00bebd;width: 50px;cursor: pointer;color: white;" onclick="enSure3(this,${wantjob.id})">确定</button></p>`;
        $(e).parent().html(str);
    })

}

function enSure3(e, id) {
    $(e).parent().parent().css("background-color", "white");
    let name = $('.ppoo').val();
    let city = $('.nop').val()
    $.get('/dev/resume/updatewantjob?wantJobId=' + id + "&jobName=" + name + "&jobCity=" + city, function (result) {
        let wantJob = result.data
        let str = `  <p>期望职位</p>
                    <p class="wj">
                        <span>${wantJob.job}</span><span>${wantJob.wantMoney}</span><span>${wantJob.industry}</span><span>${wantJob.city}</span>
                    </p>
                    <p class="set3" onclick="editSet3(this,${wantJob.id})">编辑</p>`;
        $(e).parent().parent().html(str);
    })
}


function editSetItems(e) {
    $(e).parent().css("background-color", "#EBF4F5");
    $.get('/dev/resume/selectitems', function (result) {
        let items = result.data;
        let str = '<p>项目经历</p>';
        for (let i = 0; i < items.length; i++) {
            str += `     <P class="item${items[i].id}" style="margin-left: 30px;margin-bottom: 15px;margin-top: 15px">项目名称：<input type="text" value="${items[i].itemName}" style="width: 80px;margin-right: 20px">项目时间：<input type="text" value="${items[i].alltime}" style="width: 100px"></P>
                    <P class="item${items[i].id}"  style="margin-left: 30px;margin-bottom: 15px">项目描述:<input type="text" value="${items[i].msg}" style="width: 500px;height: 50px"><button style="border: 0;background-color: #00bebd;width: 50px;cursor: pointer;color: white;margin-left: 15px" onclick="delItem(this,${items[i].id})">删除</button></P>`;
        }
        str += `<button style="border: 0;background-color: #00bebd;width: 50px;cursor: pointer;color: white;margin-left: 600px" onclick="enSureItem(this)">确定</button><button style="border: 0;background-color: #00bebd;width: 50px;cursor: pointer;color: white;margin-left: 660px;display: inline-block;position: relative;top: -18px;">新增</button>`;
        $(e).parent().html(str);
    })

}

function delItem(e, id) {
    if (id == 1) {
        $('.item1').remove();

    }
    if (id == 2) {
        $('.item2').remove();
    }
    $.get('/dev/resume/delitem?id=' + id)
}

function enSureItem(e) {
    $(e).parent().css("background-color", "white")
    $(e).parent().css("height", "190px")
    $.get('/dev/resume/selectitems', function (result) {
        let items = result.data;
        let str = `<p>项目经历</p>`;
        for (let i = 0; i < items.length; i++) {
            str += `<p class="wj">
                            <span>${items[i].itemName}</span><span>${items[i].alltime}</span>
                        </p>
                        <p class="wj" style="margin-bottom: 50px">
                            <span>${items[i].msg}</span>
                        </p>`;
        }
        str += ` <p class="set3" style="top:-35px" onclick="editSetItems(this)">编辑</p>`;
        $(e).parent().html(str);

    })

}

function myLoved() {
    $('.jobs_body_title').text("我的收藏");
    $.get('/dev/lovejob/mylovejob', function (result) {
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney = ""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples = ""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }

            jobs.innerHTML = strjobs;
        }
    })

}

function myApplyed() {
    $('.jobs_body_title').text("我的投递");
    $('.newIcon').css('display','none');
    $.get('/dev/resume/myapplyed', function (result) {
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left");
            let strjobs =`<div style="width: 884px;height: 60px;background-color: white;display: flex;border-radius: 10px;justify-content: space-around;margin-top: 10px;margin-bottom: 10px">
                        <li class="liiiii" style="background-color: #00d7c6;color: white;border-radius: 10px" onclick=" myApplyed()">全部</li>
                        <li class="liiiii" onclick="dealGo(this)">未处理</li>
                        <li class="liiiii" onclick="dealGo(this)">有意向</li>
                        <li class="liiiii" onclick="dealGo(this)">无意向</li>
                        <li class="liiiii" onclick="dealGo(this)">邀约面试</li>
                </div> <div class="myyBigBox">`;
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney = ""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples = ""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `
                <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }
            strjobs+=`</div>`;

            jobs.innerHTML = strjobs;
        }
    })
}


function dealGo(e){
        console.log($(e).text()=="未处理")
    let deal=$(e).text();
        switch (deal){
            case "未处理":
                deal=0;
                break;
            case "有意向":
                deal=1;
                break;
            case "无意向":
                deal=2;
                break;
            case "邀约面试":
                deal=3;
                break;
        }
    $('.liiiii').css("background-color","white")
    $('.liiiii').css("color","#8c8c8c")
    $(e).css("background-color","#00d7c6")
    $(e).css("color","white")
    $(e).css("border-radius","10px")
    $.get('/dev/applyed/undo?deals='+deal,function (result){
        var jobList = result.data.jobList;
        console.log(jobList);
        var companyList = result.data.companyList;
        let jobs = document.querySelector(".myyBigBox");
        let strjobs='';
        for (var i = 0; i < jobList.length; i++) {
            let schoolLevel = "";
            let workTime = "";
            switch (jobList[i].needWorktime) {
                case 0:
                    workTime = "不限"
                    break;
                case  1:
                    workTime = "应届"
                    break;
                case  2:
                    workTime = "一年以内"
                    break;
                case  3:
                    workTime = "一到三年"
                    break;
                case  4:
                    workTime = "三到五年"
                    break;
                case  5:
                    workTime = "五年以上"
                    break;
            }
            switch (jobList[i].needSchoollevel) {
                case 0:
                    schoolLevel = "大专以下"
                    break;
                case  1:
                    schoolLevel = "大专"
                    break;
                case  2:
                    schoolLevel = "本科"
                    break;
                case  3:
                    schoolLevel = "硕士"
                    break;
                case  4:
                    schoolLevel = "博士及以上"
                    break;
            }
            for (j = 0; j < companyList.length; j++) {
                if (jobList[i].companyId == companyList[j].id) {
                    let collectMoney = ""
                    switch (companyList[j].collectmoneyState) {
                        case 0:
                            collectMoney = "未融资"
                            break;
                        case  1:
                            collectMoney = "天使轮"
                            break;
                        case  2:
                            collectMoney = "A轮"
                            break;
                        case  3:
                            collectMoney = "B轮"
                            break;
                        case  4:
                            collectMoney = "C轮"
                            break;
                        case  5:
                            collectMoney = "D轮"
                            break;
                        case  6:
                            collectMoney = "已上市"
                            break;
                        case  7:
                            collectMoney = "不需要融资"
                            break;
                    }
                    let peoples = ""
                    switch (companyList[j].peopleCounts) {
                        case 0:
                            peoples = "0-20"
                            break;
                        case  1:
                            peoples = "20-99"
                            break;
                        case  2:
                            peoples = "100-499"
                            break;
                        case  3:
                            peoples = "500-999"
                            break;
                        case  4:
                            peoples = "1000-9999"
                            break;
                        case  5:
                            peoples = "10000以上"
                            break;
                    }
                    strjobs += `
                <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                }
            }
        }

        jobs.innerHTML = strjobs;
    })
}

function myNotLike(){
    $('.jobs_body_title').text("我的屏蔽");
    $.get('/dev/notlike/sel', function (result) {
        if (result.code == "OK") {
            var jobList = result.data.jobList;
            var companyList = result.data.companyList;
            let jobs = document.querySelector(".jobs_msg_left");
            let strjobs = "";
            for (var i = 0; i < jobList.length; i++) {
                let schoolLevel = "";
                let workTime = "";
                switch (jobList[i].needWorktime) {
                    case 0:
                        workTime = "不限"
                        break;
                    case  1:
                        workTime = "应届"
                        break;
                    case  2:
                        workTime = "一年以内"
                        break;
                    case  3:
                        workTime = "一到三年"
                        break;
                    case  4:
                        workTime = "三到五年"
                        break;
                    case  5:
                        workTime = "五年以上"
                        break;
                }
                switch (jobList[i].needSchoollevel) {
                    case 0:
                        schoolLevel = "大专以下"
                        break;
                    case  1:
                        schoolLevel = "大专"
                        break;
                    case  2:
                        schoolLevel = "本科"
                        break;
                    case  3:
                        schoolLevel = "硕士"
                        break;
                    case  4:
                        schoolLevel = "博士及以上"
                        break;
                }
                for (j = 0; j < companyList.length; j++) {
                    if (jobList[i].companyId == companyList[j].id) {
                        let collectMoney = ""
                        switch (companyList[j].collectmoneyState) {
                            case 0:
                                collectMoney = "未融资"
                                break;
                            case  1:
                                collectMoney = "天使轮"
                                break;
                            case  2:
                                collectMoney = "A轮"
                                break;
                            case  3:
                                collectMoney = "B轮"
                                break;
                            case  4:
                                collectMoney = "C轮"
                                break;
                            case  5:
                                collectMoney = "D轮"
                                break;
                            case  6:
                                collectMoney = "已上市"
                                break;
                            case  7:
                                collectMoney = "不需要融资"
                                break;
                        }
                        let peoples = ""
                        switch (companyList[j].peopleCounts) {
                            case 0:
                                peoples = "0-20"
                                break;
                            case  1:
                                peoples = "20-99"
                                break;
                            case  2:
                                peoples = "100-499"
                                break;
                            case  3:
                                peoples = "500-999"
                                break;
                            case  4:
                                peoples = "1000-9999"
                                break;
                            case  5:
                                peoples = "10000以上"
                                break;
                        }
                        strjobs += `   <a href="http://localhost:8088/dev/job/jobmsg?jId=${jobList[i].id}">
        <div class="jobs_msg">
            <div class="jobs_msg_top">
                <div class="jobs_msg_top_left">
                    <P>${jobList[i].name}</P>
                    <p><span>${jobList[i].minMoney}-${jobList[i].maxMoney}K</span><span>${workTime}</span><span>${schoolLevel}</span></p>
                </div>
                <div class="jobs_msg_top_right">
                    <div>
                        <img src="${companyList[j].icon}" alt="" width="60px" height="60px">
                    </div>
                    <div>
                        <p>${companyList[j].name}</p>
                        <p><span>${companyList[j].kind}</span><span>${collectMoney}</span><span>${peoples}</span></p>
                    </div>
                </div>
            </div>
            <div class="jobs_msg_bottom">
                <p><span>${jobList[i].simpleRequest}</span>
                </p>
                <p>${companyList[j].welfare}</p>
            </div>
        </div>
    </a>`;
                    }
                }
            }

            jobs.innerHTML = strjobs;
        }
    })
}

function btImg(){
$('.mydivv').css('display','block');
$('.lolo').css('display','none')
}

function changeImg(){
    var fd = new FormData();
    fd.append("file", document.getElementById("inputId").files[0]);

    // console.log($('.mmm').val())
    // $.post('/dev/api/image/upload',{file:$('.mmm').val()},function (result){
    //     console.log(result);
    // })
    $.ajax({
        url: "/dev/api/image/upload",
        type: "post",
        data: fd,
        processData: false,
        contentType: false,
        success: function (res) {
            console.log(res);
            // let imgs=res.data.imageUrl.splice("com");
            // let url = 'http://rr2xgprkx.hn-bkt.clouddn.com/'+imgs[1];
            let imgUrl=res.data.imageUrl[0];
            let imgs=imgUrl.split("com");
            let url='http://rr2xgprkx.hn-bkt.clouddn.com/'+imgs[1];
            console.log(url);
            $('.lolo').attr("src",url);
            $('.mydivv').css('display','none');
            $('.lolo').css('display','block')
            $('.opop').attr("src",url);
        },
        dataType: "json"
    })
}





